import { reactive } from 'vue'
import axios from 'axios'


// export default function 需要export返回值,可以返回函数
export default function () {
  // https://dog.ceo/api/breed/pembroke/images/random
  let picList = reactive([
    "https:\/\/images.dog.ceo\/breeds\/pembroke\/n02113023_5295.jpg",
    "https:\/\/images.dog.ceo\/breeds\/pembroke\/n02113023_6269.jpg",
    "https:\/\/images.dog.ceo\/breeds\/pembroke\/n02113023_7243.jpg"
  ])
  function getDog() {
    axios.get('https://dog.ceo/api/breed/pembroke/images/random')
      .then(res => {
        picList.push(res.data.message)
      })
      .catch(err => {
        alert(err)
      })
  }


  // 需要retrun回去东西,就是你希望给的值
  return {picList,getDog}
}


